<#import "/manage/tpl/pageBase.ftl" as page>
<@page.pageBase currentMenu="商家广告管理">
<form action="${basepath}/manage/indexImg" theme="simple" enctype="multipart/form-data">
    <span id="pifeSpan" class="input-group-addon" style="display:none">${systemSetting().imageRootPath}</span>
    <table class="table table-bordered">
        <tr style="background-color: #dff0d8">
            <td colspan="2" style="background-color: #dff0d8;text-align: center;">
                <strong>广告编辑</strong>
            </td>
        </tr>


        <tr style="display: none;">
            <th>id</th>
            <td><input type="hidden" value="${e.id!""}" name="id" label="id" id="idd"/></td>
        </tr>



        <tr>
            <th>显示位置</th>
            <td>
                <select name="type">
                    <option value="1"  <#if e.type??&&e.type=="1">selected</#if>>好店页面</option>
                    <option value="2"  <#if e.type??&&e.type=="2">selected</#if>>其他</option>
                </select>

            </td>
        </tr>


        <tr>
            <th class="right">标题</th>
            <td style="text-align: left;"><input type="text" value="${e.title!""}" name="title"
                                                 data-rule="标题:required;title;length[1~45];"
                                                 id="title"/></td>
        </tr>
        <tr>
            <th class="td_right">图片</th>
            <td style="text-align: left;">
                <input id="uploadify" name="uploadify" value="添加" class="btn btn-warning" type="button"/></td>
            </td>
        </tr>

        <tr id="firstTr">
            <th class="td_right">好店头图预览</th>
            <td>
            <#--<input type="button" name="filemanager" value="浏览图片" class="btn btn-warning"/>-->
                <img name="img" style="width:50px;height:50px;max-width: 50px;max-height: 50px;" id="picture"
                     src="${systemSetting().imageRootPath}${e.picture!""}">

                <input type="hidden" ccc="imagesInput" name="picture" style="width: 260px;"
                       readonly="readonly"
                       id="inputImage" value="${e.picture!""}"/>
            </td>
        </tr>
        <tr>
            <th>广告链接</th>
            <td style="text-align: left;">
                <input type="text" value="${e.link!""}" name="link" id="link"/>
            </td>
        </tr>
        <tr>
            <th>排序</th>
            <td style="text-align: left;"><input type="text" value="${e.order1!""}" name="order1"
                                                 data-rule="排序:integer;order1;length[1~5];"
                                                 id="order1"/></td>
        </tr>
        <tr>
            <th>描述</th>
            <td style="text-align: left;"><input type="text" value="${e.desc1!""}" name="desc1"
                                                 data-rule="排序:desc1;length[1~100];"
                                                 id="desc1"/></td>
        </tr>
        <tr>
            <td colspan="2" style="text-align: center;">
                <#if e.id??>
                    <button method="update" class="btn btn-success">
                        <i class="icon-ok icon-white"></i> 保存
                    </button>
                <#else>
                    <button method="insert" class="btn btn-success">
                        <i class="icon-ok icon-white"></i> 新增
                    </button>
                </#if>
        </tr>
    </table>
</form>


<link rel="stylesheet" href="${basepath}/resource/uploadify/uploadify.css" type="text/css">
<script type="text/javascript" src="${basepath}/resource/uploadify/jquery.uploadify.min.js"></script>
<script>
    var url = '${basepath}/common/uploadify.do?userId=shop';
    //alert(url);
    $("#uploadify").uploadify({
        //'auto'           : false,
        'swf': '${basepath}/resource/uploadify/uploadify.swf',
        'uploader': url,//后台处理的请求
        'queueID': 'fileQueue',//与下面的id对应
        //'queueSizeLimit' :100,
        //'fileTypeDesc'   : 'rar文件或zip文件',
        //'fileTypeExts' 	 : '*.jpg;*.jpg', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc
        //'fileTypeExts'   : '*.rar;*.zip', //控制可上传文件的扩展名，启用本项时需同时声明fileDesc


        //'fileTypeDesc' : '图片文件' , //出现在上传对话框中的文件类型描述
//'fileTypeExts' : '*.jpg;*.bmp;*.png;*.gif', //控制可上传文件的扩展名，启用本项时需同时声明filedesc

        'multi': true,
        'buttonText': '本地上传',

        onUploadSuccess: function (file, data, response) {
            //alert("上传成功,data="+data+",file="+file+",response="+response);
//				ajaxLoadImgList();
            data = $.parseJSON(data);
            if (data.error == '1') {
                alert("上传失败：\n失败原因:" + data.msg);
            } else {
                $("#picture").attr("src", "${systemSetting().imageRootPath}" + data.filePath);
                $("#inputImage").val(data.filePath);
                $("#firstTr").show();
            }
        },
        onUploadError: function (file, errorCode, errorMsg) {
            alert("上传失败,data=" + data + ",file=" + file + ",response=" + response);
        }
    });

</script>
</@page.pageBase>